<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>GitCodeTree Logo 生成器</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .container {
            background: white;
            border-radius: 20px;
            padding: 40px;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
            max-width: 900px;
            width: 100%;
        }

        h1 {
            text-align: center;
            color: #1a202c;
            margin-bottom: 10px;
            font-size: 2em;
        }

        .subtitle {
            text-align: center;
            color: #718096;
            margin-bottom: 40px;
        }

        .logo-preview {
            display: flex;
            justify-content: space-around;
            flex-wrap: wrap;
            gap: 30px;
            margin-bottom: 40px;
        }

        .logo-item {
            text-align: center;
        }

        .logo-box {
            width: 200px;
            height: 200px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 15px;
            margin-bottom: 15px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        }

        .logo-box.white {
            background: #ffffff;
        }

        .logo-box.dark {
            background: #1a202c;
        }

        .logo-box.transparent {
            background: 
                linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
                linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
            background-size: 20px 20px;
            background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
        }

        .logo-label {
            font-size: 14px;
            color: #4a5568;
            font-weight: 500;
        }

        .controls {
            display: flex;
            gap: 15px;
            justify-content: center;
            flex-wrap: wrap;
            margin-bottom: 30px;
        }

        .btn {
            padding: 12px 30px;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .btn-primary {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
        }

        .btn-secondary {
            background: #f1f5f9;
            color: #4a5568;
        }

        .btn-secondary:hover {
            background: #e2e8f0;
        }

        .size-selector {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-bottom: 20px;
        }

        .size-btn {
            padding: 8px 20px;
            border: 2px solid #e2e8f0;
            background: white;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 14px;
        }

        .size-btn:hover {
            border-color: #667eea;
        }

        .size-btn.active {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-color: transparent;
        }

        .info-box {
            background: #f8fafc;
            border-radius: 10px;
            padding: 20px;
            margin-top: 30px;
        }

        .info-title {
            font-weight: 600;
            color: #1a202c;
            margin-bottom: 10px;
        }

        .info-list {
            list-style: none;
            padding: 0;
        }

        .info-list li {
            padding: 5px 0;
            color: #4a5568;
            font-size: 14px;
        }

        .info-list li::before {
            content: "✓ ";
            color: #10b981;
            font-weight: bold;
            margin-right: 8px;
        }

        canvas {
            display: none;
        }

        @media (max-width: 768px) {
            .container {
                padding: 20px;
            }

            .logo-preview {
                flex-direction: column;
                align-items: center;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎨 GitCodeTree Logo</h1>
        <p class="subtitle">项目 Logo 生成器</p>

        <div class="logo-preview">
            <div class="logo-item">
                <div class="logo-box white" id="preview-white"></div>
                <div class="logo-label">白色背景</div>
            </div>
            <div class="logo-item">
                <div class="logo-box dark" id="preview-dark"></div>
                <div class="logo-label">深色背景</div>
            </div>
            <div class="logo-item">
                <div class="logo-box transparent" id="preview-transparent"></div>
                <div class="logo-label">透明背景</div>
            </div>
        </div>

        <div class="size-selector">
            <button class="size-btn" data-size="64">64x64</button>
            <button class="size-btn" data-size="128">128x128</button>
            <button class="size-btn active" data-size="200">200x200</button>
            <button class="size-btn" data-size="512">512x512</button>
            <button class="size-btn" data-size="1024">1024x1024</button>
        </div>

        <div class="controls">
            <button class="btn btn-primary" onclick="downloadLogo('png')">
                📥 下载 PNG
            </button>
            <button class="btn btn-primary" onclick="downloadLogo('svg')">
                📥 下载 SVG
            </button>
            <button class="btn btn-secondary" onclick="copyToClipboard()">
                📋 复制 SVG 代码
            </button>
        </div>

        <div class="info-box">
            <div class="info-title">📝 Logo 设计说明</div>
            <ul class="info-list">
                <li>渐变紫色主题，与应用配色一致</li>
                <li>树形结构象征项目目录结构</li>
                <li>代码符号 &lt;/&gt; 体现开发工具属性</li>
                <li>简洁现代，适合各种尺寸显示</li>
                <li>支持透明背景，适配不同场景</li>
            </ul>
        </div>
    </div>

    <canvas id="canvas"></canvas>

    <script>
        let currentSize = 200;

        const svgCode = `<svg width="${currentSize}" height="${currentSize}" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <linearGradient id="gradient1" x1="0%" y1="0%" x2="100%" y2="100%">
      <stop offset="0%" style="stop-color:#667eea;stop-opacity:1" />
      <stop offset="100%" style="stop-color:#764ba2;stop-opacity:1" />
    </linearGradient>
  </defs>
  
  <!-- 背景圆形 -->
  <circle cx="100" cy="100" r="95" fill="url(#gradient1)"/>
  
  <!-- 树形结构 -->
  <g transform="translate(100, 60)">
    <!-- 主干 -->
    <rect x="-4" y="0" width="8" height="80" fill="#ffffff" rx="4"/>
    
    <!-- 第一层分支 -->
    <g transform="translate(0, 20)">
      <line x1="0" y1="0" x2="-30" y2="15" stroke="#ffffff" stroke-width="6" stroke-linecap="round"/>
      <circle cx="-30" cy="15" r="5" fill="#ffffff"/>
      <line x1="0" y1="0" x2="30" y2="15" stroke="#ffffff" stroke-width="6" stroke-linecap="round"/>
      <circle cx="30" cy="15" r="5" fill="#ffffff"/>
    </g>
    
    <!-- 第二层分支 -->
    <g transform="translate(0, 40)">
      <line x1="0" y1="0" x2="-40" y2="20" stroke="#ffffff" stroke-width="6" stroke-linecap="round"/>
      <circle cx="-40" cy="20" r="5" fill="#ffffff"/>
      <line x1="0" y1="0" x2="0" y2="20" stroke="#ffffff" stroke-width="6" stroke-linecap="round"/>
      <circle cx="0" cy="20" r="5" fill="#ffffff"/>
      <line x1="0" y1="0" x2="40" y2="20" stroke="#ffffff" stroke-width="6" stroke-linecap="round"/>
      <circle cx="40" cy="20" r="5" fill="#ffffff"/>
    </g>
    
    <!-- 第三层小分支 -->
    <g transform="translate(0, 60)">
      <line x1="-40" y1="20" x2="-50" y2="30" stroke="#ffffff" stroke-width="4" stroke-linecap="round"/>
      <circle cx="-50" cy="30" r="4" fill="#ffffff"/>
      <line x1="-40" y1="20" x2="-30" y2="30" stroke="#ffffff" stroke-width="4" stroke-linecap="round"/>
      <circle cx="-30" cy="30" r="4" fill="#ffffff"/>
      <line x1="40" y1="20" x2="30" y2="30" stroke="#ffffff" stroke-width="4" stroke-linecap="round"/>
      <circle cx="30" cy="30" r="4" fill="#ffffff"/>
      <line x1="40" y1="20" x2="50" y2="30" stroke="#ffffff" stroke-width="4" stroke-linecap="round"/>
      <circle cx="50" cy="30" r="4" fill="#ffffff"/>
    </g>
  </g>
  
  <!-- 代码符号装饰 -->
  <text x="100" y="175" font-family="monospace" font-size="24" font-weight="bold" fill="#ffffff" text-anchor="middle" opacity="0.9">&lt;/&gt;</text>
</svg>`;

        function updatePreview() {
            const svg = svgCode.replace(/width="\d+"/, `width="${currentSize}"`).replace(/height="\d+"/, `height="${currentSize}"`);
            document.getElementById('preview-white').innerHTML = svg;
            document.getElementById('preview-dark').innerHTML = svg;
            document.getElementById('preview-transparent').innerHTML = svg;
        }

        function downloadLogo(format) {
            if (format === 'svg') {
                const blob = new Blob([svgCode], { type: 'image/svg+xml' });
                const url = URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.href = url;
                a.download = `gitcodetree-logo-${currentSize}x${currentSize}.svg`;
                a.click();
                URL.revokeObjectURL(url);
            } else if (format === 'png') {
                const canvas = document.getElementById('canvas');
                canvas.width = currentSize;
                canvas.height = currentSize;
                const ctx = canvas.getContext('2d');
                
                const img = new Image();
                img.onload = function() {
                    ctx.drawImage(img, 0, 0, currentSize, currentSize);
                    canvas.toBlob(function(blob) {
                        const url = URL.createObjectURL(blob);
                        const a = document.createElement('a');
                        a.href = url;
                        a.download = `gitcodetree-logo-${currentSize}x${currentSize}.png`;
                        a.click();
                        URL.revokeObjectURL(url);
                    });
                };
                img.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svgCode)));
            }
        }

        function copyToClipboard() {
            navigator.clipboard.writeText(svgCode).then(() => {
                alert('✓ SVG 代码已复制到剪贴板！');
            });
        }

        // 尺寸选择
        document.querySelectorAll('.size-btn').forEach(btn => {
            btn.addEventListener('click', function() {
                document.querySelectorAll('.size-btn').forEach(b => b.classList.remove('active'));
                this.classList.add('active');
                currentSize = parseInt(this.dataset.size);
                updatePreview();
            });
        });

        // 初始化
        updatePreview();
    </script>
</body>
</html>

